Optimal. Leaf size=99 \[ \frac {2 A \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}}+\frac {B \log (1-\cos (x))}{2 (a+b)}-\frac {B \log (1+\cos (x))}{2 (a-b)}+\frac {b B \log (a+b \cos (x))}{a^2-b^2} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.19, antiderivative size = 99, normalized size of antiderivative = 1.00, number of steps
used = 11, number of rules used = 8, integrand size = 15, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.533, Rules used = {4310, 4486,
2738, 211, 2747, 720, 31, 647} \begin {gather*} \frac {b B \log (a+b \cos (x))}{a^2-b^2}+\frac {2 A \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}}+\frac {B \log (1-\cos (x))}{2 (a+b)}-\frac {B \log (\cos (x)+1)}{2 (a-b)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 31
Rule 211
Rule 647
Rule 720
Rule 2738
Rule 2747
Rule 4310
Rule 4486
Rubi steps
\begin {align*} \int \frac {A+B \csc (x)}{a+b \cos (x)} \, dx &=\int \frac {\csc (x) (B+A \sin (x))}{a+b \cos (x)} \, dx\\ &=\int \left (\frac {A}{a+b \cos (x)}+\frac {B \csc (x)}{a+b \cos (x)}\right ) \, dx\\ &=A \int \frac {1}{a+b \cos (x)} \, dx+B \int \frac {\csc (x)}{a+b \cos (x)} \, dx\\ &=(2 A) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )-(b B) \text {Subst}\left (\int \frac {1}{(a+x) \left (b^2-x^2\right )} \, dx,x,b \cos (x)\right )\\ &=\frac {2 A \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}}+\frac {(b B) \text {Subst}\left (\int \frac {1}{a+x} \, dx,x,b \cos (x)\right )}{a^2-b^2}+\frac {(b B) \text {Subst}\left (\int \frac {-a+x}{b^2-x^2} \, dx,x,b \cos (x)\right )}{a^2-b^2}\\ &=\frac {2 A \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}}+\frac {b B \log (a+b \cos (x))}{a^2-b^2}+\frac {B \text {Subst}\left (\int \frac {1}{-b-x} \, dx,x,b \cos (x)\right )}{2 (a-b)}-\frac {B \text {Subst}\left (\int \frac {1}{b-x} \, dx,x,b \cos (x)\right )}{2 (a+b)}\\ &=\frac {2 A \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b}}+\frac {B \log (1-\cos (x))}{2 (a+b)}-\frac {B \log (1+\cos (x))}{2 (a-b)}+\frac {b B \log (a+b \cos (x))}{a^2-b^2}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.22, size = 116, normalized size = 1.17 \begin {gather*} \frac {-2 A \left (a^2-b^2\right ) \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {x}{2}\right )}{\sqrt {-a^2+b^2}}\right )-\sqrt {-a^2+b^2} B \left ((a+b) \log \left (\cos \left (\frac {x}{2}\right )\right )-b \log (a+b \cos (x))+(-a+b) \log \left (\sin \left (\frac {x}{2}\right )\right )\right )}{(a-b) (a+b) \sqrt {-a^2+b^2}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.17, size = 95, normalized size = 0.96
method | result | size |
default | \(\frac {\frac {B b \ln \left (a \left (\tan ^{2}\left (\frac {x}{2}\right )\right )-b \left (\tan ^{2}\left (\frac {x}{2}\right )\right )+a +b \right )}{a -b}+\frac {\left (2 a A +2 A b \right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {x}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}}{a +b}+\frac {B \ln \left (\tan \left (\frac {x}{2}\right )\right )}{a +b}\) | \(95\) |
risch | \(-\frac {2 i x B \,a^{2} b}{a^{4}-2 a^{2} b^{2}+b^{4}}+\frac {2 i x B \,b^{3}}{a^{4}-2 a^{2} b^{2}+b^{4}}+\frac {i x B}{a -b}-\frac {i x B}{a +b}+\frac {\ln \left ({\mathrm e}^{i x}+\frac {a A -i \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) B b}{\left (a +b \right ) \left (a -b \right )}+\frac {\ln \left ({\mathrm e}^{i x}+\frac {a A -i \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{\left (a +b \right ) \left (a -b \right )}+\frac {\ln \left ({\mathrm e}^{i x}+\frac {a A +i \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) B b}{\left (a +b \right ) \left (a -b \right )}-\frac {\ln \left ({\mathrm e}^{i x}+\frac {a A +i \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{\left (a +b \right ) \left (a -b \right )}-\frac {B \ln \left ({\mathrm e}^{i x}+1\right )}{a -b}+\frac {B \ln \left ({\mathrm e}^{i x}-1\right )}{a +b}\) | \(357\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 4.08, size = 265, normalized size = 2.68 \begin {gather*} \left [\frac {B b \log \left (b^{2} \cos \left (x\right )^{2} + 2 \, a b \cos \left (x\right ) + a^{2}\right ) - \sqrt {-a^{2} + b^{2}} A \log \left (\frac {2 \, a b \cos \left (x\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (x\right ) + b\right )} \sin \left (x\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (x\right )^{2} + 2 \, a b \cos \left (x\right ) + a^{2}}\right ) - {\left (B a + B b\right )} \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) + {\left (B a - B b\right )} \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right )}{2 \, {\left (a^{2} - b^{2}\right )}}, \frac {B b \log \left (b^{2} \cos \left (x\right )^{2} + 2 \, a b \cos \left (x\right ) + a^{2}\right ) + 2 \, \sqrt {a^{2} - b^{2}} A \arctan \left (-\frac {a \cos \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (x\right )}\right ) - {\left (B a + B b\right )} \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) + {\left (B a - B b\right )} \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right )}{2 \, {\left (a^{2} - b^{2}\right )}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {A + B \csc {\left (x \right )}}{a + b \cos {\left (x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.45, size = 115, normalized size = 1.16 \begin {gather*} \frac {B b \log \left (-a \tan \left (\frac {1}{2} \, x\right )^{2} + b \tan \left (\frac {1}{2} \, x\right )^{2} - a - b\right )}{a^{2} - b^{2}} - \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, x\right ) - b \tan \left (\frac {1}{2} \, x\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )} A}{\sqrt {a^{2} - b^{2}}} + \frac {B \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) \right |}\right )}{a + b} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 3.54, size = 417, normalized size = 4.21 \begin {gather*} \frac {B\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right )}{a+b}+\frac {\ln \left (3\,B\,a^2\,b^2-2\,B\,b^4-B\,a^4+A\,a\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}+A\,b\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}+A\,a^4\,\mathrm {tan}\left (\frac {x}{2}\right )+A\,b^4\,\mathrm {tan}\left (\frac {x}{2}\right )-B\,a\,b^3+B\,a^3\,b-2\,A\,a^2\,b^2\,\mathrm {tan}\left (\frac {x}{2}\right )+B\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-2\,B\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\right )\,\left (A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,b^3+B\,a^2\,b\right )}{a^4-2\,a^2\,b^2+b^4}-\frac {\ln \left (B\,a^4+2\,B\,b^4-3\,B\,a^2\,b^2+A\,a\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}+A\,b\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-A\,a^4\,\mathrm {tan}\left (\frac {x}{2}\right )-A\,b^4\,\mathrm {tan}\left (\frac {x}{2}\right )+B\,a\,b^3-B\,a^3\,b+2\,A\,a^2\,b^2\,\mathrm {tan}\left (\frac {x}{2}\right )+B\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-2\,B\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\right )\,\left (B\,b^3+A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,a^2\,b\right )}{a^4-2\,a^2\,b^2+b^4} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________